package com.dingzhen.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@ConfigurationProperties(value = "mqtt")
public class MqttProperties {

    private String appid;//客户端ID

    private String[] inputTopic;//订阅主题，可以是多个主题

    private String[] outTopic;//发布主题，可以是多个主题

    private String[] mqttServices;//服务器地址以及端口

    private String user;//用户名

    private String password;//密码

    private Integer KeepAliveInterval;//心跳时间,默认为5分钟

    private Boolean CleanSession;//是否不保持session,默认为session保持

    private Boolean AutomaticReconnect;//是否自动重联，默认为开启自动重联

    private int CompletionTimeout;//连接超时,默认为30秒

    private Integer Qos;//通信质量，详见MQTT协议

    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String[] getInputTopic() {
        return inputTopic;
    }

    public void setInputTopic(String[] inputTopic) {
        this.inputTopic = inputTopic;
    }

    public String[] getOutTopic() {
        return outTopic;
    }

    public void setOutTopic(String[] outTopic) {
        this.outTopic = outTopic;
    }

    public String[] getMqttServices() {
        return mqttServices;
    }

    public void setMqttServices(String[] mqttServices) {
        this.mqttServices = mqttServices;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getKeepAliveInterval() {
        return KeepAliveInterval;
    }

    public void setKeepAliveInterval(Integer keepAliveInterval) {
        KeepAliveInterval = keepAliveInterval;
    }

    public Boolean getCleanSession() {
        return CleanSession;
    }

    public void setCleanSession(Boolean cleanSession) {
        CleanSession = cleanSession;
    }

    public Boolean getAutomaticReconnect() {
        return AutomaticReconnect;
    }

    public void setAutomaticReconnect(Boolean automaticReconnect) {
        AutomaticReconnect = automaticReconnect;
    }

    public int getCompletionTimeout() {
        return CompletionTimeout;
    }

    public void setCompletionTimeout(int completionTimeout) {
        CompletionTimeout = completionTimeout;
    }

    public Integer getQos() {
        return Qos;
    }

    public void setQos(Integer qos) {
        Qos = qos;
    }

    @Override
    public String toString() {
        return "MqttProperties{" +
                "appid='" + appid + '\'' +
                ", inputTopic=" + Arrays.toString(inputTopic) +
                ", outTopic=" + Arrays.toString(outTopic) +
                ", mqttServices=" + Arrays.toString(mqttServices) +
                ", user='" + user + '\'' +
                ", password='" + password + '\'' +
                ", KeepAliveInterval=" + KeepAliveInterval +
                ", CleanSession=" + CleanSession +
                ", AutomaticReconnect=" + AutomaticReconnect +
                ", CompletionTimeout=" + CompletionTimeout +
                ", Qos=" + Qos +
                '}';
    }
}
